$(document).ready(function(){

	$('.Interlaced tr:odd').addClass('trbgcolor');
	$('.menu-list-title').click(function(){
		$(this).next('li').toggle('1500');
	});
	$(".menu-children li").click(function(){
		$(".menu-children li").css({background:'none'});
		$(this).css({background:'#f35844'});
	});
	show();
});

function remove(current){
	$(current).parent().parent().remove();
};

function add(){
	var tr="";
	tr=tr+'<tr><td style="text-align: right; width: 15%;">图片：</td>';
	tr=tr+'<td><input  name="file" type="file"  /></td>';
	tr=tr+	'<td><button onclick="add()" type="button"  class="btn" >添加</button>';
	tr=tr+'<button type="button" class="btn" onclick="remove(this)">删除</button></td>';
	tr=tr+'</tr>';
	$("#add-tbody").append(tr);
}
//展示一级
function show(){
	var select="";
	$.ajax({
		url : 'type/get',
		type : 'POST',
		data:{'fkParentId':5},
		success : function(data) {
			var list=data.data;
			var tr="";
			select="";
			for ( var i in list) {
				select=select+"<option value='"+list[i].uid+"'>"+list[i].name+"</option>";
			}
			$("#firstSelect").append(select);
		}
	});
}

/**
 * 展示详细
 * @returns
 */
function showDetail(current){
	if(current.value=""){
		return;
	}
	var tr="";
	$("#info-table").html("");
	var tr="";
	tr=tr+'</tr>';
	$.ajax({
		url : 'type/get',
		type : 'POST',
		data:{'fkParentId':current},
		success : function(data) {
			var list=data.data;
			select="";
			for ( var i in list) {
				tr=tr+'<tr >';
				tr=tr+'<td class="td1">'+(parseInt(i)+1)+'</td>';
				tr=tr+'<td class="td2">'+list[i].name+'</td>';
				tr=tr+'</tr>';
				select=select+"<option value='"+list[i].uid+"'>"+list[i].name+"</option>";
			}
			$("#secondSelect").append(select);
			$("#info-table").append(tr);
		}
	});
}
